package cn.learn.activiti.listener;

import cn.learn.activiti.interceptor.MyCommandInterceptor;
import org.activiti.engine.delegate.event.ActivitiEventListener;
import org.activiti.engine.impl.interceptor.CommandInterceptor;
import org.activiti.spring.SpringProcessEngineConfiguration;
import org.activiti.spring.boot.ProcessEngineConfigurationConfigurer;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @author huangyezhan
 * @version 1.0
 * @date 2021年03月18日13:05
 */
@Component
public class ActivitiConfig implements ProcessEngineConfigurationConfigurer {


    @Override
    public void configure(SpringProcessEngineConfiguration processEngineConfiguration) {
        List<ActivitiEventListener> activitiEventListener = new ArrayList<>();
        // 配置全局监听器
        activitiEventListener.add(new MyActivitiEventListener());
        processEngineConfiguration.setEventListeners(activitiEventListener);

        // 拦截器
        List<CommandInterceptor> commandInterceptors = new ArrayList<>();
        commandInterceptors.add(new MyCommandInterceptor());
//        processEngineConfiguration.setCustomPreCommandInterceptors(commandInterceptors);

        System.out.println("================================注册监听================================");

    }

}
